package march.test_3_6;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        for(int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            Stack<Integer> stack = new Stack<>();
            for(int j = 0; j < 2*n; j++) {
                stack.push(scanner.nextInt());
            }
            print(result(stack,k));
            System.out.println();
        }
    }
    public static Stack<Integer> result(Stack<Integer> stack,int k) {
        int size = stack.size();
        while(k > 0) {
            Stack<Integer> st1 = new Stack<>();
            Stack<Integer> st2 = new Stack<>();
            int i = size / 2;
            while (i > 0) {
                st1.push(stack.pop());
                i--;
            }
            while (!stack.empty()) {
                st2.push(stack.pop());
            }
            while ( !st1.empty()) {
                stack.push(st2.pop());
                stack.push(st1.pop());
            }
            k--;
        }
        return stack;
    }
    public static void print(Stack<Integer> stack) {
        if(!stack.empty()) {
            int tmp = stack.pop();
            print(stack);
            System.out.print(tmp+ " ");
        } else {
            return;
        }
    }
}
